 <script type="text/javascript">
var operates = [
<#list (dto.TOperates)! as m>
<#if m_index != 0>,</#if>
'${m.id.menu}-${m.id.op}'
</#list>
];
$(function() {
	IDMark_A = "_a";
	/* 初始化功能树 */
	$.fn.zTree.init($('#menuTree'), {
		data : {
			simpleData : {
				enable : true
			}
		},
		view: {
			addDiyDom: function(treeId, treeNode) {
				var aObj = $("#" + treeNode.tId + IDMark_A);
				var html = [];
				for(var i=0;i<treeNode.operates.length;i++) {
					var op = treeNode.operates[i];
					html.push(" <label><input class=\"operates\" type=\"checkbox\" name=\"operates\" value=\""+op.id+"\""+($.inArray(op.id,operates)!=-1?" checked":"")+">"+op.name+"</label>");
				}
				aObj.after(html.join(""));
			}
		},
		callback : {
			onClick : function(event, treeId, treeNode, clickFlag) {
				//
			}
		}
	}, [ 
	<#list menus! as m>
	<#if m_index != 0>,</#if>{
		"id" : '${m.id}',
		"pId" : '${(m.TMenu.id)!0}',
		"name" : "${(m.name)!}",
		"open" : true,
		"operates" : [
			<#list m.TOperates! as o>
			<#if o_index != 0>,</#if>
			{"id" : '${o.id.menu}-${o.id.op}', "name" : '${o.name}'}
			</#list>
		]
	}
	</#list>
	]);
	
	
	
 	sy.admin.menu${(OP.TMenu.id)!}.save = function() {
  		if($("#menu${(OP.TMenu.id)!}Form").valid()){
  			$.ajax({
				type: "POST", 
				url: "op_save_${(OP.TMenu.id)!}.action",
				data: $('#menu${(OP.TMenu.id)!}Form').serializeArray(),
				dataType: "json",
				success: function(data){
					if(data.success) {
						sy.closeWindow();
						$('#admin_menu${(OP.TMenu.id)!}_datagrid').bootstrapTable('refresh');
					}
					sy.toastrsAlert({
		       		     code: data.success ? 'success' :'error',
		       		     msg: data.success ? '成功' :'失败'
		       		});
				}
			});
  		}
		 
	}
 	/* $("#checkAll").click(function(){
 		var $this = $(this);
 		 $("input[name='operates']").each(function(){
 			    console.info($this.prop("checked"));
 			   $(this).attr("checked",$this.prop("checked"));
 			  });  
 	}); */
});


</script>
       <div class="wrapper wrapper-content gray-bg bgg animated  ${(cfg.animated)!}   "   style="height:100%">
                <div class="ibox">
                    <div class="ibox-content">
                    
                    <form class="form-horizontal m-t required-validate"  id="menu${(OP.TMenu.id)!}Form"   action="op_save_${(OP.TMenu.id)!}.${(cfg.suffix)!'action'}"  method="post">
                    <input type="hidden" name="id" value="${(dto.id)!}"/>
                    
                           <div class="form-group">
                                <label class="col-sm-3 control-label">角色名称：</label>
                                <div class="col-sm-8">
                                   <input  name="name" class="form-control" value="${(dto.name)!}" validate="{required:true,messages:{required:'请填写名称'}}" type="text">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">角色代码：</label>
                                <div class="col-sm-8">
                                <#if !dto.id??>
                                   <input  name="code" class="form-control" value="${(dto.code)!}" validate="{required:true,messages:{required:'请填写代码'}}" type="text">
                                <#else>
                                   <span style="display: block;   margin-top: 6px;">${(dto.code)!}</span>
						           <input type="hidden" name="code" class="formText" value="${(dto.code)!}" />
                                </#if>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label">权限：</label>
                                <div class="col-sm-8" >
                                    <div  style="width: 470px; height:auto ; overflow: auto; border-width: 1px; border-color: #ccc; border-style: solid; padding: 1px;">
							    		<div id="menuTree" class="ztree"></div>
							    	</div>
							    	<label><input id="checkAll"  onclick="$('.operates').prop('checked',($(this).prop('checked') ? true : false ))"   type="checkbox" />全选/不选 </label>
                                </div>
                            </div>
                             <!--   -->
                             <div class="form-group">
                                <label class="col-sm-3 control-label">备注：</label>
                                <div class="col-sm-8">
                                       <textarea id="ccomment" name="remark" cols="55" rows="3" class="form-control" >${(dto.remark?html)!}</textarea>
                                </div>
                            </div>
                             
                        </form>
                        
                    </div>
                </div>
                </div>
